package com.baizhi.service.impl;

import com.baizhi.entity.Role;
import com.baizhi.entity.RoleResource;
import com.baizhi.mapper.RoleResourceMapper;
import com.baizhi.service.IRoleResourceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author longyang
 * @since 2022-01-13
 */
@Service
public class RoleResourceServiceImpl extends ServiceImpl<RoleResourceMapper, RoleResource> implements IRoleResourceService {
    @Autowired
    private RoleResourceMapper roleResourceMapper;
    @Override
    public Integer addRoleResource(RoleResource roleResource) {
        return roleResourceMapper.insert(roleResource);
    }

    @Override
    public List<RoleResource> slectRoleResource(Integer roleId) {
        //条件构造器：用于构建sql条件
        QueryWrapper<RoleResource> queryWrapper = new QueryWrapper<RoleResource>();
        queryWrapper.eq("role_id",roleId);
        List<RoleResource> roleResources = roleResourceMapper.selectList(queryWrapper);
        return roleResources;
    }
}
